# 1. 写入文件
with open("demo.txt", "w") as file:
    file.write("Hello from Python!\nThis is a test file.")

# 2. 读取文件
with open("demo.txt", "r") as file:
    content = file.read()
    print(content)